Skip to content

chore(#10543): add PERSON contact type constant and replace magic strings#11235

Open
Saish31 wants to merge 3 commits into
medic:masterfrom
Saish31:10543-add-person-constant
Open

chore(#10543): add PERSON contact type constant and replace magic strings#11235
Saish31 wants to merge 3 commits into
medic:masterfrom
Saish31:10543-add-person-constant

Conversation

@Saish31

@Saish31 Saish31 commented Jul 4, 2026

Copy link
Copy Markdown

Description

Adds a PERSON constant to CONTACT_TYPES in @medic/constants, and replaces hardcoded 'person' magic strings with CONTACT_TYPES.PERSON across the codebase where the string represents a contact/doc type check (not an id, and not inside a CouchDB view function).

Changes

  • shared-libs/constants/src/index.js: added PERSON: 'person' to CONTACT_TYPES
  • shared-libs/contact-types-utils/src/index.js
  • shared-libs/transitions/src/transitions/registration.js
  • shared-libs/cht-datasource/src/local/person.ts
  • shared-libs/contacts/src/people.js
  • webapp/web-components/cht-form/src/app.component.ts
  • webapp/src/ts/services/contact-save.service.ts
  • admin/src/js/services/import-contacts.js

Intentionally not changed

  • ddocs/medic-db/medic-client/views/contacts_by_type/map.js and contacts_by_parent/map.js, and webapp/src/js/bootstrapper/offline-ddocs/medic-offline-freetext/*.js: these are CouchDB map functions that get serialized via .toString() and executed by CouchDB in complete isolation — they cannot require() shared constants.
  • Occurrences where 'person' is used as an id value rather than a type check (e.g. test fixtures, contact: 'person').
  • config/demo/** and config/default/** sample app configuration files, which aren't part of the @medic/* shared-lib ecosystem.

Testing

Ran unit tests for every affected package locally, all passing:

  • shared-libs/contact-types-utils: 56 passing, 100% coverage
  • shared-libs/transitions: 879 passing
  • shared-libs/cht-datasource: 1055 passing
  • shared-libs/contacts: 83 passing, 100% coverage
  • webapp (incl. cht-form): 2796 passing
  • admin: 431 passing

Also ran eslint on all changed files with no errors.

AI Disclosure

Used Claude to review code changes as this was my first open source contribution.

Fixes #10543

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add constant for 'person' document type

1 participant